#pragma once

#include "activeobject.h"

namespace RoomFW {

//
// Class:	HsmMessageHandler
//
// Description:	ActiveObject::MessageHandler derived Hierarchical State Machine.
//
// Author:	Andrew Sage
//
class HsmMessageHandler : public QHsm, public ActiveObject::MessageHandler
{
public:

	//
	// Method:	HsmMessageHandler
	//
	// Description:	Constructor
	//
	// Parameters:
	//
	//	initialState - QHsm constructor arguement.
	//
	HsmMessageHandler(ActiveObject* parent, QState initialState);

	//
	// Method:	~HsmMessageHandler
	//
	// Description:	Destructor
	//
	virtual ~HsmMessageHandler();

	//
	// Method:	handle
	//
	// Description:	ActiveObject override to pass message to QHsm::dispatch().
	//
	// Parameters:
	//
	//	message - RoomMessage to handle.
	//
	// Return:	None
	//
	virtual bool handle(RoomMessageSP message);

protected:

	//
	// Method:	getCurrentMessage
	//
	// Description:	Allow HsmMessageHandler's access to the actual RoomMessageSP, not just the bare
	//              pointer
	//
	// Parameters: None
	//
	// Return:
	//
	//	message - current RoomMessage being handled;
	//
	RoomMessageSP getCurrentMessage();

	//
	// Method:	setMessageHandled
	//
	// Description:	Notify base class that message was handled.
	//
	// Parameters: None
	//
	// Return:	None
	//
	void setMessageHandled();

private:

	//
	// Stores message currently being handled.
	//
	RoomMessageSP currentMessage_;

	//
	// Flag if current message was handled.
	//
	bool messageHandled_;
};

}
